package amap;

import cn.hutool.http.HttpResponse;
import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;

import com.onLineCar.common.core.domain.Result;
import org.springframework.beans.factory.annotation.Value;

import com.onLineCar.amap.domain.AMapRouteData;


/**
 * @program: onLineCar-server
 * @description:
 * @author: godGuang
 * @create: 2023-12-13 17:25
 **/
public class test {

    @Value("${aMap.key}")
    static String key;

    public static void main(String[] args) {


        AMapRouteData route = getRoute("121.69773,30.871043", "121.808682,31.142267");



        System.out.println(route.getRoute());
        System.out.println(route.getStatus());
        System.out.println(route.getInfo());
        System.out.println(route.getInfocode());
        System.out.println(route.getCount());


        Result<AMapRouteData> result = Result.success(route);

        System.out.println(JSON.toJSONString(route));


    }





    public static AMapRouteData getRoute(String origin, String destination) {

        String url = "https://restapi.amap.com/v3/direction/driving?origin="+origin+"&destination="+destination+"&extensions=all&key=0dcf0b900421a4d64f350d525886781a";
        System.out.println(url);
        HttpResponse response = HttpUtil.createGet(url).execute();
        if (null==response){
            System.out.println("调用失败");
        }

        return JSONObject.parseObject(response.body(), AMapRouteData.class);

    }

}

